

#ifndef _UCGI_H
#define _UCGI_H 1

#define UCGI_SERVICES  UCRX_T("UcGiServices")

#include "zacgidefs.h"


#include "zrxobject.h"
#include "zAdAChar.h"
#include "zdbpl.h"
#include "zgemat3d.h"
#include "zgemat2d.h"
#include "zgepnt2d.h"
#include "zdbcolor.h"
#include "zacdb.h"
#include "zAcGiStyleAttributes.h"
#include "assert.h"
#include "zacgiparameter.h"

#pragma pack (push, 8)

struct UcGiSentScanLines 
{
    enum IsmRequestStatus {
        eOk,                           
        eInvalidInput,                 
        eInvalidColorDepth,            
        eInvalidPixelRequest,          
        eInvalidDeliveryMethod,        
        eNoValidCompressors,           
        eInsufficientMemory            
    };

    ZSoft::Int8 *    mpPixelBuffer;          
    ZSoft::UInt32    mRowBytes;              
    void *           mpImageId;              
    ZSoft::Int16     mIsCancelled;           
    ZSoft::Int16     mHasFailed;
    ZSoft::UInt32    mBytes;
    IsmRequestStatus mRequestStatus;

};

struct UcGiRequestScanLines 
{
    enum IEDitherMethod 
    {
        kIEAnyPalette,
        kCustomDithering,
        kCustomDitheringMethod
    };

    enum IEColorSystem
    {
        kBitonal,
        kCMY,
        kCMYK,
        kRGB
    };

    enum ImagePaletteType
    {
        kFromDevice,
        kFromIeWholeImage
    };

    UcGiRequestScanLines()
        : mPixelMinX          (0)
        , mPixelMinY          (0)
        , mPixelMaxX          (0)
        , mPixelMaxY          (0)
        , mpImageId           (0)
        , mImageOrg           (kUcGiBitonal)
        , mImageOrient        (kUcGiXLeftToRightTopFirst)
        , mWindowId           (0)
        , mColorDepth         (8)
        , mPaletteIncarnation (0)
        , mpPalette           (0)
        , mIsDisplay          (0)
        , mRasterRatio        (1.0)
        , mPaletteType        (kFromDevice)
        , mpDataBuffer        (0)
        , mRowWidth           (0)
        , mpBoundaryPoints    (0)
        , mnContours          (0)
        , mpCounts            (0)
        , mScalingType        (kDefaultScale)
        , mScaleFilterType    (kDefaultScaleFilter)
        , mRotationFilterType (kDefaultRotationFilter)
        , mnTotalChunks       (0)
        , mnThisChunk         (0)
    {
    }

    ZSoft::UInt32       mPixelMinX;             
    ZSoft::UInt32       mPixelMinY;
    ZSoft::UInt32       mPixelMaxX;
    ZSoft::UInt32       mPixelMaxY;
    UcGePoint2d         mLowerLeft;             
    UcGePoint2d         mUpperRight;            
    void *              mpImageId;              
    UcGiImageOrg        mImageOrg;              
    UcGiImageOrient     mImageOrient;           
    ZSoft::Int16        mWindowId;              
    ZSoft::Int16        mColorDepth;            
    union {
        ZSoft::Int16 mBackgroundIndex;
        ZSoft::Int8 mBackgroundRGB[3];
    }                   mBackgroundColor;       
    union {
        ZSoft::Int16 mTransparentIndex;
        ZSoft::Int8 mTransparentRGB[3];
    } mTransparentColor;                        
    union {
        ZSoft::Int16 mEntityIndex;
        ZSoft::Int8 mEntityRGB[3];
    }                   mEntityColor;           
    ZSoft::Int32        mPaletteIncarnation;    
    ZSoft::Int8 *       mpPalette;              
    ZSoft::Int16        mIsDisplay;             
    double              mRasterRatio;           
    UcGeMatrix2d        mPixelToDc;             
    ImagePaletteType    mPaletteType;
    void *              mpDataBuffer;
    ZSoft::Int32        mRowWidth;
    ZSoft::Int32        mNumRows;
    ZSoft::Int32 const *mpBoundaryPoints;        
    ZSoft::UInt32       mnContours;              
    ZSoft::Int32 const *mpCounts;                
    UcGiScaleType          mScalingType;
    UcGiScaleFilterType    mScaleFilterType;
    UcGiRotationFilterType mRotationFilterType;
    short                  mnTotalChunks;
    short                  mnThisChunk;
	ZSoft::Int32		mOrigin[2];
	ZSoft::Int32		mLowerRightPt[2];
	ZSoft::Int32		mUpperLeftPt[2];
};

struct UcGiClipBoundary
{
    UcGeVector3d        m_vNormal;
    UcGePoint3d         m_ptPoint;
    UcGePoint2dArray    m_aptPoints;    

    UcGeMatrix3d        m_xToClipSpace;
    UcGeMatrix3d        m_xInverseBlockRefXForm; 

    ZSoft::Boolean      m_bClippingFront;
    ZSoft::Boolean      m_bClippingBack;
    double              m_dFrontClipZ;
    double              m_dBackClipZ;

    ZSoft::Boolean      m_bDrawBoundary;
};

class OwnerDraw3d
{
public:
    virtual ~OwnerDraw3d(void) {};
};

typedef enum UcGiColorIntensity 
{
    kUcGiMinColorIntensity = 0x0,
    kUcGiColorIntensity1   = 0x1,
    kUcGiColorIntensity2   = 0x2,
    kUcGiColorIntensity3   = 0x3,
    kUcGiColorIntensity4   = 0x4,
    kUcGiColorIntensity5   = 0x5,
    kUcGiColorIntensity6   = 0x6,
    kUcGiMaxColorIntensity = 0x7 
};

class UcGiColorRGB
{
public:
    UcGiColorRGB (void)
        : red   (0.0)
        , green (0.0)
        , blue  (0.0)
    { }

    UcGiColorRGB (double r, double g, double b)
        : red   (r)
        , green (g)
        , blue  (b)
    { }

    double red;
    double green;
    double blue;
};

inline UcGiColorRGB operator* (const UcGiColorRGB& c1, const UcGiColorRGB& c2)
{
    return UcGiColorRGB(c1.red   * c2.red,
                        c1.green * c2.green,
                        c1.blue  * c2.blue);
}

inline UcGiColorRGB operator* (const UcGiColorRGB& c, double s)
{
    return UcGiColorRGB(s * c.red,
                        s * c.green,
                        s * c.blue);
}

inline UcGiColorRGB operator* (double s, const UcGiColorRGB& c)
{
    return c * s;
}

inline UcGiColorRGB operator+ (const UcGiColorRGB& c1, const UcGiColorRGB& c2)
{
    return UcGiColorRGB(c1.red   + c2.red,
                        c1.green + c2.green,
                        c1.blue  + c2.blue);
}

class UcGiColorRGBA
{
public:
    UcGiColorRGBA (void)
        : red   (0.0)
        , green (0.0)
        , blue  (0.0)
        , alpha (1.0)
    { }

    UcGiColorRGBA (double r, double g, double b, double a)
        : red   (r)
        , green (g)
        , blue  (b)
        , alpha (a)
    { }

    double red;
    double green;
    double blue;
    double alpha;
};

inline UcGiColorRGBA operator* (const UcGiColorRGBA& c1, const UcGiColorRGBA& c2)
{
    return UcGiColorRGBA(c1.red   * c2.red,
                         c1.green * c2.green,
                         c1.blue  * c2.blue,
                         c1.alpha * c2.alpha);
}

inline UcGiColorRGBA operator*(const UcGiColorRGBA& c, double s)
{
    return UcGiColorRGBA(s * c.red,
                         s * c.green,
                         s * c.blue,
                         s * c.alpha);
}

inline UcGiColorRGBA operator* (double s, const UcGiColorRGBA& c)
{
    return c * s;
}

inline UcGiColorRGBA operator+ (const UcGiColorRGBA& c1, const UcGiColorRGBA& c2)
{
    return UcGiColorRGBA(c1.red   + c2.red,
                         c1.green + c2.green,
                         c1.blue  + c2.blue,
                         c1.alpha + c2.alpha);
}

class UcGiPixelBGRA32
{
public:
	UcGiPixelBGRA32 ()
	{
		m_bgra.b = 0;
		m_bgra.g = 0;
		m_bgra.r = 0;
		m_bgra.a = 255;
	}

	UcGiPixelBGRA32(ZSoft::UInt32 bgra)
		: m_whole (bgra)
	{
	}

	UcGiPixelBGRA32 (ZSoft::UInt8 blue,
		ZSoft::UInt8 green,
		ZSoft::UInt8 red,
		ZSoft::UInt8 alpha)
	{
		m_bgra.b = blue;
		m_bgra.g = green;
		m_bgra.r = red;
		m_bgra.a = alpha;
	}

	ZSoft::UInt32     getBGRA   () const;
	ZSoft::UInt32     getRGBA   () const;
	ZSoft::UInt8      blue      () const;
	ZSoft::UInt8      green     () const;
	ZSoft::UInt8      red       () const;
	ZSoft::UInt8      alpha     () const;

	void setBGRA    (ZSoft::UInt32 bgra);
	void setBGRA    (ZSoft::UInt8 blue, 
						ZSoft::UInt8 green, 
						ZSoft::UInt8 red,
						ZSoft::UInt8 alpha);
	void setRGBA    (ZSoft::UInt32 rgba);
	void setRGBA    (ZSoft::UInt8 red, 
						ZSoft::UInt8 green, 
						ZSoft::UInt8 blue,
						ZSoft::UInt8 alpha);
	void setBlue    (ZSoft::UInt8 blue);
	void setGreen   (ZSoft::UInt8 green);
	void setRed     (ZSoft::UInt8 red);
	void setAlpha   (ZSoft::UInt8 alpha);

private:
	union {
		ZSoft::UInt32 m_whole;
#if defined(_ZSOFT_WINDOWS_)
		struct PIXEL{
#else
		// The GCC compiler requires the PIXEL struct to be anonymous as well.
		// I don't think we need the PIXEL struct identifier, so this should work.
		// If not, we'll have to provide a name for the union and update al the code
		// to use that name.
		//
		struct {
#endif
			ZSoft::UInt8  b, g, r, a;
		}m_bgra;
	};
};

inline ZSoft::UInt32 UcGiPixelBGRA32::getBGRA() const
{
	return m_whole;
}

inline ZSoft::UInt32 UcGiPixelBGRA32::getRGBA() const
{
	return (ZSoft::UInt32)(m_bgra.a)<<24 
		| (ZSoft::UInt32)(m_bgra.b)<<16
		| (ZSoft::UInt32)(m_bgra.g)<<8 
		| (ZSoft::UInt32)(m_bgra.r);
}

inline ZSoft::UInt8 UcGiPixelBGRA32::blue() const
{
	return m_bgra.b;
}

inline ZSoft::UInt8 UcGiPixelBGRA32::green() const
{
	return m_bgra.g;
}

inline ZSoft::UInt8 UcGiPixelBGRA32::red() const
{
	return m_bgra.r;
}

inline ZSoft::UInt8 UcGiPixelBGRA32::alpha() const
{
	return m_bgra.a;
}

inline void UcGiPixelBGRA32::setBGRA(ZSoft::UInt32 bgra)
{
	m_whole = bgra;
}

inline void UcGiPixelBGRA32::setBGRA(ZSoft::UInt8 blue, 
	ZSoft::UInt8 green, 
	ZSoft::UInt8 red,
	ZSoft::UInt8 alpha)
{
	m_bgra.b = blue;
	m_bgra.g = green;
	m_bgra.r = red;
	m_bgra.a = alpha;
}

inline void UcGiPixelBGRA32::setRGBA(ZSoft::UInt32 rgba)
{
	m_bgra.r = (ZSoft::UInt8)(rgba & 0x000000FF);
	m_bgra.g = (ZSoft::UInt8)((rgba & 0x0000FF00) >> 8);
	m_bgra.b = (ZSoft::UInt8)((rgba & 0x00FF0000) >> 16);
	m_bgra.a = (ZSoft::UInt8)((rgba & 0xFF000000) >> 24);
}

inline void UcGiPixelBGRA32::setRGBA(ZSoft::UInt8 red, 
	ZSoft::UInt8 green, 
	ZSoft::UInt8 blue,
	ZSoft::UInt8 alpha)
{
	m_bgra.r = red;
	m_bgra.g = green;
	m_bgra.b = blue;
	m_bgra.a = alpha;
}

inline void UcGiPixelBGRA32::setBlue(ZSoft::UInt8 blue)
{
	m_bgra.b = blue;
}

inline void UcGiPixelBGRA32::setGreen(ZSoft::UInt8 green)
{
	m_bgra.g = green;
}

inline void UcGiPixelBGRA32::setRed(ZSoft::UInt8 red)
{
	m_bgra.r = red;
}

inline void UcGiPixelBGRA32::setAlpha(ZSoft::UInt8 alpha)
{
	m_bgra.a = alpha;
}

class UcGiImageBGRA32
{
public:
	UcGiImageBGRA32()
		: m_nImageWidth(0)
		, m_nImageHeight(0)
		, m_pImageData(NULL)
	{
	}

	UcGiImageBGRA32(ZSoft::UInt32 imageWidth, ZSoft::UInt32 imageHeight, UcGiPixelBGRA32* imageData)
		: m_nImageWidth(imageWidth)
		, m_nImageHeight(imageHeight)
		, m_pImageData(imageData)
	{
	}

	UcGiPixelBGRA32* image() const;
	ZSoft::UInt32 width() const;
	ZSoft::UInt32 height() const;
	void setImage(ZSoft::UInt32 imageWidth, ZSoft::UInt32 imageHeight, UcGiPixelBGRA32* imageData);

private:
	UcGiPixelBGRA32* m_pImageData;
	ZSoft::UInt32 m_nImageWidth;
	ZSoft::UInt32 m_nImageHeight;
};

inline 
UcGiPixelBGRA32* UcGiImageBGRA32::image() const
{
	return m_pImageData;
}

inline 
ZSoft::UInt32 UcGiImageBGRA32::width() const
{
	return m_nImageWidth;
}

inline 
ZSoft::UInt32 UcGiImageBGRA32::height() const
{
	return m_nImageHeight;
}

inline 
void UcGiImageBGRA32::setImage(ZSoft::UInt32 imageWidth, ZSoft::UInt32 imageHeight, UcGiPixelBGRA32* imageData)
{
	m_nImageWidth   = imageWidth;
	m_nImageHeight  = imageHeight;
	m_pImageData    = imageData;
}

class UcGiSubEntityTraits;
class UcGiDrawableTraits;
class UcGiSubEntityTraitsImp;
class UcGiWorldGeometry;
class UcGiViewport;
class UcGiViewportGeometry;
class UcGiImpEdgeData;
class UcGiImpFaceData;
class UcGiImpVertexData;
class UcGiImpTextStyle;
class UcGiTextStyle;
class UcGiEdgeData;
class UcGiFaceData;
class UcGiVertexData;
class OwnerDraw;
class UcGiImpVariant;
class UcGiVariant;
class UcGiContextImp;
class UcGiContext;
class UcGiCommonDraw;
class UcGiGeometry;
class UcCmEntityColor;
struct TextParams;
struct FontInfo;
class UcGiMapper;
class UcGiViewportTraits;
class UcGiVisualStyleTraits;
class UcGiEdgeStyle;
class UcGiContextualColors;
class UcGiGdiDrawObject;
class UcGiFill;
typedef void (*UcGiWorldSegmentCallback)(const UcGePoint3d *);

bool ucgiIsValidClipBoundary(const UcGePoint2dArray& pts);

class UcGiVariant : public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcGiVariant);

    UcGiVariant(void);
    virtual ~UcGiVariant(void);

    UcGiVariant             (const UcGiVariant & value);
    UcGiVariant & operator= (const UcGiVariant & value);
    virtual bool  operator==(const UcGiVariant & value) const;

    virtual Ucad::ErrorStatus copyFrom(const UcRxObject* other);

    enum VariantType
    {
        kUndefined = 0,
        kBoolean,
        kInt,
        kDouble,
        kColor,
        kString,
        kTable,
    };

    class EnumType
    {
    public:
        explicit EnumType (int value) : m_value(value) { }
        
        template <typename T>
        operator T () { return static_cast<T>(m_value); }

        template <typename T>
        bool operator== (T right) const { return static_cast<int>(right) == m_value; }

        template <typename T>
        bool operator!= (T right) const { return !(*this == right); }

    protected:    
        int m_value;
    };

    UcGiVariant(bool);
    UcGiVariant(ZSoft::Int32);
    UcGiVariant(double);
    UcGiVariant(const UcCmColor&); 
    UcGiVariant(const ZTCHAR *); 

    VariantType type() const;

    void                set(bool);
    void                set(ZSoft::Int32);
    void                set(double);
    void                set(const UcCmColor&); 
    void                set(const ZTCHAR *); 

    bool                asBoolean() const;
    int                 asInt() const;
    double              asDouble() const;
    UcCmColor           asColor() const;
    UcString            asString() const;
    UCDB_PORT float               asFloat() const;
    UCDB_PORT char                asChar() const;
    UCDB_PORT unsigned char       asUchar() const;
    UCDB_PORT short               asShort() const;
    UCDB_PORT unsigned short      asUshort() const;
    UCDB_PORT unsigned int        asUint() const;
    UCDB_PORT ZSoft::Int32                asLong() const;
    UCDB_PORT ZSoft::UInt32       asUlong() const;
    UCDB_PORT EnumType            asEnum() const;
	Ucad::ErrorStatus   getElem(const ZTCHAR *, UcGiVariant & value) const;
	const UcGiVariant*  getElem(const ZTCHAR *) const;
	void                setElem(const ZTCHAR *, const UcGiVariant&);
    void                deleteElem(const ZTCHAR *);

    int                 getElemCount() const;
	Ucad::ErrorStatus   getElemAt(int, ZTCHAR*&, UcGiVariant &) const; 
	UcGiVariant*        getElemAt(int, ZTCHAR*&) const;                

    static bool         isEquivalent(const UcGiVariant*, const UcGiVariant*);

private:
    UcGiImpVariant * mpUcGiImpVariant;
};

template <typename T>
inline bool operator== (T left, const UcGiVariant::EnumType right)
{
	return (right == left);
}

template <typename T>
inline bool operator!= (T left, const UcGiVariant::EnumType right)
{
	return (right != left);
}



class UcGiContext : public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcGiContext);

    virtual ZSoft::Boolean          isPsOut() const = 0;
    virtual ZSoft::Boolean          isPlotGeneration() const = 0;
    virtual UcDbDatabase *          database() const = 0;
    virtual bool             isBoundaryClipping() const = 0;

    virtual void          disableFastMoveDrag() const{};

    virtual bool isNesting() const { return false; }

    virtual UcCmEntityColor   effectiveColor() const { return UcCmEntityColor(); }
    virtual UcDb::LineWeight  byBlockLineWeight() const { return UcDb::kLnWt000; }
    virtual UcDbObjectId      byBlockPlotStyleNameId() const { return NULL; }
    virtual UcDbObjectId      byBlockMaterialId() const { return UcDbObjectId::kNull; }

    virtual bool supportsTrueTypeText() { return false; }
    virtual bool supportsOwnerDraw() {return false;}
	virtual bool supportsFillTrait() const { return false; }

    virtual UcGiContextImp * getImpPtr() { return nullptr; }
    virtual const UcGiContextImp * getConstImpPtr() const { return nullptr; }
	virtual void setProperty(ZSoft::Int32 propertyFlag, bool bIsSet = true) {}
protected:

    friend class UcGiTextHook;
    friend class CShFont;
    friend class UcDbImpText;

    virtual UcGiWorldSegmentCallback wSegTaker() const { return nullptr; }
    virtual int getTrueTypeBoundingBox(UcGePoint3d const & location,
                                       const wchar_t * text,
                                       int length, TextParams const * tp,
                                       UcGePoint3d * bbox, float * char_widths)
                                        { return 0; }
    
    virtual int getTrueTypeTextExtents(ZTCHAR const *,unsigned int,double,
                                       int,int,
                                       int,short,short,double,double,
                                       UcGePoint2d &,UcGePoint2d &) 
                                       { return -1; }

    virtual int setTrueTypeTransform(const UcGePoint3d &,const UcGeVector3d &,
                                     double,double,double,bool,bool) 
                                     { return 0; }

    virtual int drawTrueTypeText(const ZTCHAR *,double,int,bool,
                                 const TextParams &,unsigned int){ return 0; }
    virtual int restoreTrueTypeTransform() { return 0; }
    virtual void bypassHiddenLineRemoval() { return; }
    virtual int setTextStyle(int);
    virtual ZSoft::LongPtr loadTrueTypeFont(const ZTCHAR *,
                                            bool,bool,int,int,FontInfo &)
                                  { return 0; }

};

class UcGiCommonDraw : public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcGiCommonDraw);
    virtual UcGiRegenType           regenType() const = 0;
    virtual ZSoft::Boolean          regenAbort() const = 0;
    virtual UcGiSubEntityTraits&    subEntityTraits() const = 0;
    virtual UcGiGeometry *   rawGeometry() const = 0;
    virtual ZSoft::Boolean          isDragging() const = 0;

    virtual double                deviation(const UcGiDeviationType, 
                                            const UcGePoint3d&) const = 0;
    virtual ZSoft::UInt32           numberOfIsolines() const = 0;
    
    virtual UcGiContext *      context() = 0;
    virtual bool               secondaryCall() const { return false; }
};

class UcGiWorldDraw: public UcGiCommonDraw
{
public:
    UCRX_DECLARE_MEMBERS(UcGiWorldDraw);
    virtual UcGiWorldGeometry&      geometry() const = 0;
};

class UcGiViewportDraw: public UcGiCommonDraw 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiViewportDraw);
    virtual UcGiViewport&        viewport() const = 0;
    virtual UcGiViewportGeometry& geometry() const = 0;
    virtual ZSoft::UInt32        sequenceNumber() const = 0;
    virtual ZSoft::Boolean       isValidId(const ZSoft::ULongPtr ucgiId) const =0;
    virtual UcDbObjectId         viewportObjectId() const = 0;
};

class UcGiViewport: public UcRxObject 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiViewport);

    virtual void getModelToEyeTransform(UcGeMatrix3d&) const = 0;
    virtual void getEyeToModelTransform(UcGeMatrix3d&) const = 0;
    virtual void getWorldToEyeTransform(UcGeMatrix3d&) const = 0;
    virtual void getEyeToWorldTransform(UcGeMatrix3d&) const = 0;

    virtual ZSoft::Boolean isPerspective() const = 0;
    virtual ZSoft::Boolean doPerspective(UcGePoint3d&) const = 0;
    virtual ZSoft::Boolean doInversePerspective(UcGePoint3d&) const = 0;

    virtual void getNumPixelsInUnitSquare(const UcGePoint3d& givenWorldpt,
                                  UcGePoint2d& pixelArea,
                                  bool includePerspective = true) const = 0;
    virtual void getCameraLocation(UcGePoint3d& location) const = 0;
    virtual void getCameraTarget(UcGePoint3d& target) const = 0;
    virtual void getCameraUpVector(UcGeVector3d& upVector) const = 0;

    virtual ZSoft::ULongPtr viewportId() const = 0;
    virtual ZSoft::Int16  ucadWindowId() const = 0;
    virtual void getViewportDcCorners(UcGePoint2d& lower_left,
                                      UcGePoint2d& upper_right) const = 0;

    virtual ZSoft::Boolean getFrontAndBackClipValues(ZSoft::Boolean& clip_front,
                                         ZSoft::Boolean& clip_back,
                                         double& front,
                                         double& back) const = 0;

    virtual double linetypeScaleMultiplier() const = 0;

    virtual double linetypeGenerationCriteria() const = 0;

    virtual ZSoft::Boolean layerVisible(const UcDbObjectId & idLayer) const { return ZSoft::kTrue; }

    virtual UcGeVector3d viewDir() const { return UcGeVector3d::kZAxis; }
    virtual const UcGiContextualColors* contextualColors() const { return NULL; }
};

class UcGiContextualColors : public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcGiContextualColors);
    virtual ZSoft::UInt32 gridMajorLines() const = 0;
    virtual ZSoft::UInt32 gridMinorLines() const = 0;
    virtual ZSoft::UInt32 gridAxisLines() const = 0;
    virtual int gridMajorLineTintXYZ() const = 0;
    virtual int gridMinorLineTintXYZ() const = 0;
    virtual int gridAxisLineTintXYZ() const = 0;

    virtual ZSoft::UInt32 lightGlyphs() const = 0;
    virtual ZSoft::UInt32 lightHotspot() const = 0;
    virtual ZSoft::UInt32 lightFalloff() const = 0;
    virtual ZSoft::UInt32 lightStartLimit() const = 0;
    virtual ZSoft::UInt32 lightEndLimit() const = 0;

    virtual ZSoft::UInt32 cameraGlyphs() const = 0;
    virtual ZSoft::UInt32 cameraFrustrum() const = 0;
    virtual ZSoft::UInt32 cameraClipping() const = 0;
    virtual void setContextFlags(ZSoft::UInt32 flg, bool set = true) = 0;
    virtual bool flagsSet(ZSoft::UInt32 flg) const = 0;
};

class UcGiContextualColors2 : public UcGiContextualColors
{
public:
    UCRX_DECLARE_MEMBERS(UcGiContextualColors2);

    virtual UcCmColor     webMeshColor        (void) const = 0;
    virtual UcCmColor     webMeshMissingColor (void) const = 0;
    virtual UcCmColor     lightShapeColor     (void) const = 0;
    virtual UcCmColor     lightDistanceColor  (void) const = 0;
};

#define UcGiSelectionMarkerUCADReserveStart         (-2147483647 - 1)
#define UcGiSelectionMarkerUCADReserveEnd           (UcGiSelectionMarkerUCADReserveStart + 65535)

#define UcGiSelectionMarkerUCADSelectionPreviewOff  (UcGiSelectionMarkerUCADReserveStart + 1)
#define UcGiSelectionMarkerUCADSelectionPreviewOn   (UcGiSelectionMarkerUCADReserveStart + 2)

class UcGiSubEntityTraits: public UcRxObject 
{
public:
    UCRX_DECLARE_MEMBERS(UcGiSubEntityTraits);

    enum DrawFlags
    {
        kNoDrawFlags        =   0,
        kDrawBackfaces      =   1,
        kDrawHatchGroup     =   2,
		kDrawFrontfacesOnly =   4,
		kDrawGradientFill   =   8,
		kDrawSolidFill      =   16,
		kDrawNoLineWeight   =   32,
		kDrawNoOptimization =   64,
		kDrawUseUcGiEntityForDgnLineType = 128,
		kDrawFillTextBoundaryStart       = 256,
		kDrawFillTextBoundaryEnd         = 512,
		kDrawFillSelectionWindow         = 1024
    };

    enum ShadowFlags
    {
        kShadowsCastAndReceive  = 0x00,
        kShadowsDoesNotCast     = 0x01,
        kShadowsDoesNotReceive  = 0x02,
        kShadowsIgnore          = kShadowsDoesNotCast | kShadowsDoesNotReceive,
    };

	enum SelectionFlags
	{
		kNoSelectionFlags   =   0x00,
		kSelectionIgnore    =   0x01
	};

    virtual void              setColor              (const ZSoft::UInt16 color) = 0;
    virtual void              setTrueColor          (const UcCmEntityColor& color) = 0;
    virtual void              setLayer              (const UcDbObjectId layerId) = 0;
    virtual void              setLineType           (const UcDbObjectId linetypeId) = 0;
    virtual void              setSelectionMarker    (const ZSoft::LongPtr markerId) = 0;
    virtual void              setFillType           (const UcGiFillType) = 0;
    virtual void              setLineWeight         (const UcDb::LineWeight lw) = 0;
    virtual void              setLineTypeScale      (double dScale = 1.0) = 0;
    virtual void              setThickness          (double dThickness) = 0;
    virtual void              setVisualStyle        (const UcDbObjectId visualStyleId);
    virtual Ucad::ErrorStatus setEdgeStyleOverride  (UcGiEdgeStyleMask mask, const UcGiEdgeStyle& edgeStyle);
    virtual void              setPlotStyleName      (UcDb::PlotStyleNameType type, const UcDbObjectId & id = UcDbObjectId::kNull) {}
    virtual void              setMaterial           (const UcDbObjectId materialId);
    virtual void              setMapper             (const UcGiMapper * mapper);
    virtual void              setSectionable        (bool bSectionable);
    virtual Ucad::ErrorStatus setDrawFlags          (ZSoft::UInt32 flags);
    virtual Ucad::ErrorStatus setShadowFlags        (ShadowFlags flags);
    virtual void              setSelectionGeom      (bool bSelectionflag);
	virtual void              setTransparency       (const UcCmTransparency& transparency);
	virtual void              setFill               (const UcGiFill* pFill);

    virtual ZSoft::UInt16           color               (void) const = 0;
    virtual UcCmEntityColor         trueColor           (void) const = 0;
    virtual UcDbObjectId            layerId             (void) const = 0;
    virtual UcDbObjectId            lineTypeId          (void) const = 0;
    virtual UcGiFillType            fillType            (void) const = 0;
    virtual UcDb::LineWeight        lineWeight          (void) const = 0;
    virtual double                  lineTypeScale       (void) const = 0;
    virtual double                  thickness           (void) const = 0;
    virtual UcDbObjectId            visualStyle         (void) const;
    virtual Ucad::ErrorStatus       edgeStyleOverride   (UcGiEdgeStyleMask& mask, UcGiEdgeStyle& edgeStyle) const;
    virtual UcDb::PlotStyleNameType getPlotStyleNameId  (UcDbObjectId& idResult) const { return UcDb::kPlotStyleNameByLayer ; }
    virtual UcDbObjectId            materialId          (void) const;
    virtual const UcGiMapper *      mapper              (void) const;
    virtual bool                    sectionable         (void) const;
    virtual ZSoft::UInt32           drawFlags           (void) const;
    virtual ShadowFlags             shadowFlags         (void) const;
    virtual bool                    selectionGeom       (void) const;
	virtual UcCmTransparency        transparency        (void) const;
	virtual const UcGiFill*         fill                (void) const;

	virtual void pushMarkerOverride(bool /*flag*/, const ZSoft::LongPtr /*markerId*/) { }
	virtual void popMarkerOverride(void) { }
	virtual void clearMarkerOverride(void) { }
};

inline void
UcGiSubEntityTraits::setMaterial(const UcDbObjectId materialId)
{
}

inline UcDbObjectId
UcGiSubEntityTraits::materialId(void) const
{
    return UcDbObjectId::kNull;
}

inline
void UcGiSubEntityTraits::setMapper (const UcGiMapper * mapper)
{
}

inline const UcGiMapper *
UcGiSubEntityTraits::mapper (void) const
{
    return NULL;
}

inline void
UcGiSubEntityTraits::setVisualStyle(UcDbObjectId visualStyleId)
{
}

inline UcDbObjectId
UcGiSubEntityTraits::visualStyle(void) const
{
    return UcDbObjectId::kNull;
}

inline Ucad::ErrorStatus
UcGiSubEntityTraits::setEdgeStyleOverride (UcGiEdgeStyleMask mask, const UcGiEdgeStyle& edgeStyle)
{
    return Ucad::eNotImplementedYet;
}

inline Ucad::ErrorStatus
UcGiSubEntityTraits::edgeStyleOverride (UcGiEdgeStyleMask& mask, UcGiEdgeStyle& edgeStyle) const
{
    return Ucad::eNotImplementedYet;
}

inline void
UcGiSubEntityTraits::setSectionable(bool bSectionable)
{
}

inline bool
UcGiSubEntityTraits::sectionable(void) const
{
    return false;
}

inline Ucad::ErrorStatus
UcGiSubEntityTraits::setDrawFlags (ZSoft::UInt32 flags)
{
    return Ucad::eNotImplementedYet;
}

inline ZSoft::UInt32
UcGiSubEntityTraits::drawFlags (void) const
{
    return 0;
}

inline Ucad::ErrorStatus
UcGiSubEntityTraits::setShadowFlags (ShadowFlags flags)
{
    return Ucad::eNotImplementedYet;
}

inline UcGiSubEntityTraits::ShadowFlags
UcGiSubEntityTraits::shadowFlags (void) const
{
    return kShadowsCastAndReceive;
}

inline void
UcGiSubEntityTraits::setSelectionGeom ( bool )
{
}

inline bool
UcGiSubEntityTraits::selectionGeom ( void ) const
{
    return false;
}

inline 
void UcGiSubEntityTraits::setTransparency (const UcCmTransparency&)
{
}


inline 
UcCmTransparency UcGiSubEntityTraits::transparency (void) const
{
	return UcCmTransparency();
}

inline 
void UcGiSubEntityTraits::setFill(const UcGiFill * /*pFill*/)
{
}

inline const UcGiFill *UcGiSubEntityTraits::fill(void) const
{
	return nullptr;
}

class UcGiDrawableTraits: public UcGiSubEntityTraits 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiDrawableTraits);
	enum HighlightProperty
	{
		kVertexRolloverHighlightSize,
	};
    virtual void setupForEntity(UcDbEntity * pEntity);
    virtual void addLight(const UcDbObjectId& lightId);

	virtual void              setLinePattern       (const UcGiLineType linePattern);
	virtual UcGiLineType      linePattern          (void) const;

	virtual Ucad::ErrorStatus setSelectionFlags    (const SelectionFlags flags);
	virtual SelectionFlags    selectionFlags       (void) const;

	virtual Ucad::ErrorStatus setHighlightProperty (HighlightProperty property, UcGiVariant& value);
	virtual UcGiVariant       highlightProperty    (HighlightProperty property) const;

	virtual UcGiContext      *context              (void) const { return nullptr; }

protected:
	friend class            UcDbLayerTableRecord;

    enum LayerFlags {
        kNone       = 0x00,
        kOff        = 0x01,
        kFrozen     = 0x02,
        kZero       = 0x04,
		kLocked     = 0x08
    };

    virtual void    setLayerFlags       (ZSoft::UInt8 flags)        { };
};

inline void
UcGiDrawableTraits::addLight(const UcDbObjectId& lightId)
{
}

inline 
void UcGiDrawableTraits::setLinePattern (const UcGiLineType /*linePattern*/)
{
}

inline 
UcGiLineType UcGiDrawableTraits::linePattern (void) const
{
	return kLineTypeSolid;
}

inline 
Ucad::ErrorStatus UcGiDrawableTraits::setSelectionFlags (const SelectionFlags /*flags*/)
{
	return Ucad::eOk;
}

inline 
UcGiSubEntityTraits::SelectionFlags	UcGiDrawableTraits::selectionFlags (void) const
{
	return kNoSelectionFlags;
}

inline 
Ucad::ErrorStatus UcGiDrawableTraits::setHighlightProperty(HighlightProperty /*property*/, UcGiVariant&       /*value*/)
{
	return Ucad::eOk;
}

inline 
UcGiVariant	UcGiDrawableTraits::highlightProperty(HighlightProperty /*property*/) const
{
	return UcGiVariant();
}

class UcGiNonEntityTraits : public UcGiDrawableTraits
{
public:
    UCRX_DECLARE_MEMBERS(UcGiNonEntityTraits);
    virtual void                setupForEntity      (UcDbEntity* pEntity);
    virtual void                addLight(const UcDbObjectId& id);
    virtual void                setColor            (const ZSoft::UInt16 color);
    virtual ZSoft::UInt16       color               (void) const;
    virtual void                setTrueColor        (const UcCmEntityColor& color);
    virtual UcCmEntityColor     trueColor           (void) const;
    virtual void                setLayer            (const UcDbObjectId layerId);
    virtual UcDbObjectId        layerId             (void) const;
    virtual void                setLineType         (const UcDbObjectId linetypeId);
    virtual UcDbObjectId        lineTypeId          (void) const;
    virtual void                setSelectionMarker  (const ZSoft::LongPtr markerId);
    virtual void                setFillType         (const UcGiFillType fillType);
    virtual UcGiFillType        fillType            (void) const;
    virtual void                setLineWeight       (const UcDb::LineWeight lw);
    virtual UcDb::LineWeight    lineWeight          (void) const;
    virtual void                setThickness        (double thickness);
    virtual double              thickness           (void) const;
    virtual void                setLineTypeScale    (double dScale);
    virtual double              lineTypeScale       (void) const;
    virtual void                setMaterial         (const UcDbObjectId matId);
    virtual UcDbObjectId        materialId          (void) const;
    virtual void                setSelectionGeom    (bool bSelectionflag);
    virtual bool                selectionGeom       ( void ) const;

	virtual void                setTransparency     (const UcCmTransparency& transparency);
	virtual UcCmTransparency    transparency        (void) const;

};

inline void
UcGiNonEntityTraits::setupForEntity (UcDbEntity* pEntity)
{
    assert(false);
}

inline void
UcGiNonEntityTraits::addLight(const UcDbObjectId& id)
{
    assert(false);
}

inline void
UcGiNonEntityTraits::setColor (const ZSoft::UInt16 color)
{
    assert(false);
}

inline ZSoft::UInt16
UcGiNonEntityTraits::color (void) const
{
    assert(false);
    return 0;
}

inline void
UcGiNonEntityTraits::setTrueColor (const UcCmEntityColor& color)
{
    assert(false);
}

inline UcCmEntityColor
UcGiNonEntityTraits::trueColor (void) const
{
    assert(false);
    return UcCmEntityColor();
}

inline void
UcGiNonEntityTraits::setLayer (const UcDbObjectId layerId)
{
    assert(false);
}

inline UcDbObjectId
UcGiNonEntityTraits::layerId (void) const
{
    assert(false);
    return UcDbObjectId::kNull;
}

inline void
UcGiNonEntityTraits::setLineType (const UcDbObjectId linetypeId)
{
    assert(false);
}

inline UcDbObjectId UcGiNonEntityTraits::lineTypeId (void) const
{
    assert(false);
    return  UcDbObjectId::kNull;
}

inline void
UcGiNonEntityTraits::setMaterial(const UcDbObjectId matId)
{
    assert(false);
}

inline UcDbObjectId UcGiNonEntityTraits::materialId (void) const
{
    assert(false);
    return  UcDbObjectId::kNull;
}

inline void
UcGiNonEntityTraits::setSelectionMarker (const ZSoft::LongPtr markerId)
{
    assert(false);
}

inline void
UcGiNonEntityTraits::setFillType (const UcGiFillType fillType)
{
    assert(false);
}

inline UcGiFillType
UcGiNonEntityTraits::fillType (void) const
{
    assert(false);
    return kUcGiFillAlways;
}

inline void
UcGiNonEntityTraits::setLineWeight (const UcDb::LineWeight lw)
{
    assert(false);
}

inline UcDb::LineWeight
UcGiNonEntityTraits::lineWeight (void) const
{
    assert(false);
    return UcDb::kLnWt000;
}

inline void
UcGiNonEntityTraits::setThickness (double thickness)
{
    assert(false);
}

inline double
UcGiNonEntityTraits::thickness (void) const
{
    assert(false);
    return 0.0;
}

inline void
UcGiNonEntityTraits::setLineTypeScale (double dScale)
{
    assert(false);
}

inline double
UcGiNonEntityTraits::lineTypeScale (void) const
{
    assert(false);
    return 0.0;
}

inline void
UcGiNonEntityTraits::setSelectionGeom ( bool )
{
    assert(false);
}

inline bool
UcGiNonEntityTraits::selectionGeom ( void ) const
{
    assert(false);
    return false;
}

inline
void UcGiNonEntityTraits::setTransparency (const UcCmTransparency& )  
{ 
	assert(false);
}

inline 
UcCmTransparency UcGiNonEntityTraits::transparency (void) const
{ 
	assert(false);
	return UcCmTransparency(); 
}


#ifndef _WINDEF_
struct HDC__ ;
typedef     struct HDC__ *          HDC;
#endif

class UcGiGdiDrawObject: public UcRxObject
{
public:
	UCRX_DECLARE_MEMBERS(UcGiGdiDrawObject);

	virtual ZSoft::Boolean    draw(HDC hDC, int x, int y, int w, int h) = 0;
	virtual int               width() const = 0;
	virtual int               height() const = 0;

	virtual void              addRef() = 0;
	virtual void              delRef() = 0;
};

class UcGiPolyline
{
public:
	UcGiPolyline()
		: m_nbPoints(0)
		, m_pVertexList(NULL)
		, m_pNormal(NULL)
		, m_lBaseSubEntMarker(-1)
		, m_linetypeGen(kEndToEnd)
		, m_pSubEntMarkerList(NULL)
		, m_pArcSegmentFlags(NULL)
	{ }

	UcGiPolyline (ZSoft::UInt32 nbPoints,
		UcGePoint3d*   pVertexList,
		UcGeVector3d*  pNormal = NULL,
		ZSoft::LongPtr lBaseSubEntMarker = -1)
		: m_nbPoints(nbPoints)
		, m_pVertexList(pVertexList)
		, m_pNormal(pNormal)
		, m_lBaseSubEntMarker(lBaseSubEntMarker)
		, m_linetypeGen(kEndToEnd)
		, m_pSubEntMarkerList(NULL)
		, m_pArcSegmentFlags(NULL)
	{
	}
	enum LinetypeGeneration 
	{
		kPerSegment, 
		kEndToEnd 
	};

	ZSoft::UInt32         points() const;
	const UcGePoint3d*    vertexList() const;
	const UcGeVector3d*   normal() const;
	LinetypeGeneration    linetypeGen() const;
	ZSoft::LongPtr        baseSubEntMarker() const;
	const ZSoft::LongPtr* subEntMarkerList() const;
	const bool*           arcSegmentFlags() const;

	void setVertexList(ZSoft::UInt32 nbPoints, const UcGePoint3d* pVertexList);
	void setNormal(const UcGeVector3d* pNormal);
	void setLinetypeGen(LinetypeGeneration ltgen);
	void setBaseSubEntMarker(ZSoft::LongPtr lBaseSubEntMarker);
	void setSubEntMarkerList(const ZSoft::LongPtr* pSubEntMarkerList);
	void setArcSegmentFlags(const bool* pArcSegmentFlags);

private:
	ZSoft::UInt32         m_nbPoints;
	const UcGePoint3d*    m_pVertexList;
	const UcGeVector3d*   m_pNormal;
	LinetypeGeneration    m_linetypeGen;
	ZSoft::LongPtr        m_lBaseSubEntMarker;
	const ZSoft::LongPtr* m_pSubEntMarkerList;
	const bool*           m_pArcSegmentFlags;
};

inline ZSoft::UInt32 UcGiPolyline::points() const
{
	return m_nbPoints;
}

inline const UcGePoint3d* UcGiPolyline::vertexList() const
{
	return m_pVertexList;
}

inline const UcGeVector3d* UcGiPolyline::normal() const
{
	return m_pNormal;
}

inline ZSoft::LongPtr UcGiPolyline::baseSubEntMarker() const
{
	return m_lBaseSubEntMarker;
}

inline UcGiPolyline::LinetypeGeneration UcGiPolyline::linetypeGen() const
{
	return m_linetypeGen;
}

inline const ZSoft::LongPtr* UcGiPolyline::subEntMarkerList() const
{
	return m_pSubEntMarkerList;
}

inline const bool* UcGiPolyline::arcSegmentFlags() const
{
	return m_pArcSegmentFlags;
}

inline void UcGiPolyline::setVertexList(ZSoft::UInt32 nbPoints, const UcGePoint3d* pVertexList)
{
	m_nbPoints = nbPoints;
	m_pVertexList = pVertexList;
}

inline void UcGiPolyline::setNormal(const UcGeVector3d*  pNormal)
{
	m_pNormal = pNormal;
}

inline void UcGiPolyline::setBaseSubEntMarker(ZSoft::LongPtr lBaseSubEntMarker)
{
	m_lBaseSubEntMarker = lBaseSubEntMarker;
}

inline void UcGiPolyline::setLinetypeGen(UcGiPolyline::LinetypeGeneration ltgen)
{
	m_linetypeGen = ltgen;
}

inline void UcGiPolyline::setSubEntMarkerList(const ZSoft::LongPtr* pSubEntMarkerList)
{
	m_pSubEntMarkerList = pSubEntMarkerList;
}

inline void UcGiPolyline::setArcSegmentFlags(const bool* pArcSegmentFlags)
{
	m_pArcSegmentFlags = pArcSegmentFlags;
}

typedef enum { 
	kAcGiWorldPosition,
	kAcGiViewportPosition,
	kAcGiScreenPosition,
	kAcGiScreenLocalOriginPosition,
	kAcGiWorldWithScreenOffsetPosition
} UcGiPositionTransformBehavior;

typedef enum { 
	kAcGiWorldScale,
	kAcGiViewportScale,
	kAcGiScreenScale,
	kAcGiViewportLocalOriginScale,
	kAcGiScreenLocalOriginScale
} UcGiScaleTransformBehavior;

typedef enum { 
	kAcGiWorldOrientation,
	kAcGiScreenOrientation,
	kAcGiZAxisOrientation
} UcGiOrientationTransformBehavior;

class UcGiGeometry: public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcGiGeometry);
	enum TransparencyMode
	{
		kTransparencyOff,
		kTransparency1Bit,
		kTransparency8Bit,
	};
    virtual void getModelToWorldTransform(UcGeMatrix3d&) const = 0;
    virtual void getWorldToModelTransform(UcGeMatrix3d&) const = 0;

    virtual ZSoft::Boolean pushModelTransform(const UcGeVector3d & vNormal) = 0;
    virtual ZSoft::Boolean pushModelTransform(const UcGeMatrix3d & xMat) = 0;
    virtual ZSoft::Boolean popModelTransform() = 0;

    virtual ZSoft::Boolean  circle(const UcGePoint3d& center,
                                   const double radius,
                                   const UcGeVector3d& normal) const = 0;

    virtual ZSoft::Boolean  circle(const UcGePoint3d&, const UcGePoint3d&,
                                   const UcGePoint3d&) const = 0;

    virtual ZSoft::Boolean  circularArc(const UcGePoint3d& center,
                                   const double radius,
                                   const UcGeVector3d& normal,
                                   const UcGeVector3d& startVector,
                                   const double sweepAngle,
                                   const UcGiArcType arcType = kUcGiArcSimple) const = 0;

    virtual ZSoft::Boolean  circularArc(const UcGePoint3d& start,
                                   const UcGePoint3d& point,
                                   const UcGePoint3d& end,
                                   const UcGiArcType arcType = kUcGiArcSimple) const = 0;

    virtual ZSoft::Boolean  polyline(const ZSoft::UInt32 nbPoints,
                                   const UcGePoint3d* pVertexList,
                                   const UcGeVector3d* pNormal = NULL,
                                   ZSoft::LongPtr lBaseSubEntMarker = -1) const = 0;

    virtual ZSoft::Boolean  polygon(const ZSoft::UInt32 nbPoints,
                                   const UcGePoint3d* pVertexList) const = 0;

    virtual ZSoft::Boolean  mesh(const ZSoft::UInt32 rows,
                                 const ZSoft::UInt32 columns,
                                 const UcGePoint3d* pVertexList,
                                 const UcGiEdgeData* pEdgeData = NULL,
                                 const UcGiFaceData* pFaceData = NULL,
                                 const UcGiVertexData* pVertexData = NULL,
                                 const bool bAutoGenerateNormals = true
                                 ) const = 0;

    virtual ZSoft::Boolean  shell(const ZSoft::UInt32 nbVertex,
                                 const UcGePoint3d* pVertexList,
                                 const ZSoft::UInt32 faceListSize,
                                 const ZSoft::Int32* pFaceList,
                                 const UcGiEdgeData* pEdgeData = NULL,
                                 const UcGiFaceData* pFaceData = NULL,
                                 const UcGiVertexData* pVertexData = NULL,
                                 const struct resbuf* pResBuf = NULL,
                                 const bool bAutoGenerateNormals = true
                                 ) const = 0;

    virtual ZSoft::Boolean  text(const UcGePoint3d& position,
                                 const UcGeVector3d& normal,
                                 const UcGeVector3d& direction,
                                 const double height,
                                 const double width,
                                 const double oblique,
                                 const ZTCHAR* pMsg) const = 0;

    virtual ZSoft::Boolean  text(const UcGePoint3d& position,
                                 const UcGeVector3d& normal,
                                 const UcGeVector3d& direction,
                                 const ZTCHAR* pMsg,
                                 const ZSoft::Int32 length,
                                 const ZSoft::Boolean raw,
                                 const UcGiTextStyle &pTextStyle
                                 ) const = 0;

    virtual ZSoft::Boolean  xline(const UcGePoint3d&,
                                  const UcGePoint3d&) const = 0;

    virtual ZSoft::Boolean  ray(const UcGePoint3d&,
                                const UcGePoint3d&) const = 0;

    virtual ZSoft::Boolean  pline(const UcDbPolyline& lwBuf,
                                  ZSoft::UInt32 fromIndex = 0,
                                  ZSoft::UInt32 numSegs = 0
                                  ) const = 0;

    virtual ZSoft::Boolean  draw(UcGiDrawable*) const = 0;

    virtual ZSoft::Boolean          pushClipBoundary(UcGiClipBoundary * pBoundary) = 0;
    virtual void                    popClipBoundary() = 0;
    virtual ZSoft::Boolean   worldLine(const UcGePoint3d pnts[2]) {
                                        UcGePoint3d polyPnts[2];
                                        UcGeMatrix3d mat;
                                        getWorldToModelTransform(mat);
                                        polyPnts[0] = mat * pnts[0];
                                        polyPnts[1] = mat * pnts[1];
                                        return polyline(2, polyPnts);
                                    };

    virtual ZSoft::Boolean  polypoint( const ZSoft::UInt32 nbPoints,
                                       const UcGePoint3d* pVertexList,
                                       const UcGeVector3d* pNormal = NULL,
                                       const ZSoft::LongPtr *pSubEntMarkers = NULL ) const {
                                           UcGePoint3d pline[2];
                                           ZSoft::Boolean retval = ZSoft::kFalse;
                                           for (ZSoft::UInt32 i = 0; i < nbPoints; i++) {
                                               pline[1] = pline[0] = pVertexList[i];
                                               retval = polyline(2, pline, pNormal ? &pNormal[i] : NULL, pSubEntMarkers ? pSubEntMarkers[i] : -1);
                                               if (retval)
                                                   return retval;
                                           }
                                           return retval;
                                    };
	virtual ZSoft::Boolean ownerDraw(UcGiGdiDrawObject*        pObject,
                                    const UcGePoint3d&         position,
                                    const UcGeVector3d&        u,
                                    const UcGeVector3d&        v) const { return ZSoft::kTrue; };

};

class UcGiWorldGeometry: public UcGiGeometry 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiWorldGeometry);

    virtual void setExtents(UcGePoint3d *pNewExtents) const = 0;

    virtual void startAttributesSegment() {};
};

class UcGiViewportGeometry: public UcGiGeometry 
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiViewportGeometry);

    virtual ZSoft::Boolean  polylineEye(const ZSoft::UInt32 nbPoints,
                                const UcGePoint3d* pPoints) const = 0;
    virtual ZSoft::Boolean  polygonEye(const ZSoft::UInt32 nbPoints,
                                const UcGePoint3d* pPoints) const = 0;

    virtual ZSoft::Boolean  polylineDc(const ZSoft::UInt32 nbPoints,
                                const UcGePoint3d* pPoints) const = 0;
    virtual ZSoft::Boolean  polygonDc(const ZSoft::UInt32 nbPoints,
                                const UcGePoint3d* pPoints) const = 0;

    enum ImageSource {
        kFromDwg,
        kFromOleObject,
        kFromRender
    };

    virtual ZSoft::Boolean  rasterImageDc(
                const UcGePoint3d& origin,
                const UcGeVector3d& u,
                const UcGeVector3d& v,
                const UcGeMatrix2d& pixelToDc,
                UcDbObjectId entityId,
                UcGiImageOrg imageOrg,
                ZSoft::UInt32 imageWidth,
                ZSoft::UInt32 imageHeight,
                ZSoft::Int16 imageColorDepth,
                ZSoft::Boolean transparency,
                ImageSource source,
                const UcGeVector3d& unrotatedU,
                const UcGiImageOrg origionalImageOrg,
                const UcGeMatrix2d& unrotatedPixelToDc,
                const ZSoft::UInt32 unrotatedImageWidth,
                const ZSoft::UInt32 unrotatedImageHeight
                ) const = 0;

    virtual ZSoft::Boolean  ownerDrawDc(
                ZSoft::Int32                       vpnumber, 
                ZSoft::Int32                       left, 
                 ZSoft::Int32                        top, 
                 ZSoft::Int32                        right, 
                 ZSoft::Int32                        bottom, 
                const OwnerDraw*           pOwnerDraw
                ) const = 0;

    virtual ZSoft::Boolean  ownerDraw3d(
                UcGePoint3d&               minBounds,
                UcGePoint3d&               maxBounds,
                OwnerDraw3d*               pOwnerDraw
                ) const  { return ZSoft::kFalse; };
};

class UcGiEdgeData  : public UcRxObject
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiEdgeData);

    ~UcGiEdgeData();
    UcGiEdgeData();

    virtual void            setColors(const short *colors);
    virtual void            setTrueColors(const UcCmEntityColor *colors);
    virtual void            setLayers(const UcDbObjectId *layers);
    virtual void            setLineTypes(const UcDbObjectId *linetypes);
    virtual void            setSelectionMarkers(const ZSoft::LongPtr* pSelectionMarkers);
    virtual void            setVisibility(const ZSoft::UInt8* pVisibility);

    virtual short*          colors() const;
    virtual UcCmEntityColor* trueColors() const;
    virtual UcDbObjectId*   layerIds() const;
    virtual UcDbObjectId*   linetypeIds() const;
    virtual ZSoft::LongPtr* selectionMarkers() const;
    virtual ZSoft::UInt8*   visibility() const;
private:
	UcGiImpEdgeData *mpUcGiImpEdgeData;
};

class UcGiFaceData : public UcRxObject
{ 
public:
    UCRX_DECLARE_MEMBERS(UcGiFaceData);

    ~UcGiFaceData();
    UcGiFaceData();
    virtual void            setColors(const short *colors);
    virtual void            setTrueColors(const UcCmEntityColor *colors);
    virtual void            setLayers(const UcDbObjectId *layers);
    virtual void            setSelectionMarkers(const ZSoft::LongPtr* pSelectionMarkers);
    virtual void            setNormals(const UcGeVector3d* pNormals);
    virtual void            setVisibility(const ZSoft::UInt8* vis);
    virtual void            setMaterials(const UcDbObjectId * materials);
    virtual void            setMappers(const UcGiMapper * mappers);
	virtual void            setTransparency(const UcCmTransparency *transparency);

    virtual short*          colors() const;
    virtual UcCmEntityColor* trueColors() const;
    virtual UcDbObjectId*   layerIds() const;
    virtual ZSoft::LongPtr* selectionMarkers() const;
    virtual UcGeVector3d*   normals() const;
    virtual ZSoft::UInt8*   visibility() const;
    virtual UcDbObjectId*   materials() const;
    virtual UcGiMapper*     mappers() const;
	virtual UcCmTransparency* transparency() const;
private:
	UcGiImpFaceData *mpUcGiImpFaceData;
};

class UcGiVertexData: public UcRxObject 
{ 
public:
    enum MapChael
    {
        kAllChaels,
        kMapChaels
    };

    UCRX_DECLARE_MEMBERS(UcGiVertexData);
    ~UcGiVertexData();
    UcGiVertexData();
    virtual void setNormals(const UcGeVector3d* pNormals);
    virtual UcGeVector3d* normals() const;
    virtual void setOrientationFlag(const UcGiOrientationType oflag); 
    virtual UcGiOrientationType orientationFlag() const;
    virtual void setTrueColors(const UcCmEntityColor *colors);
    virtual UcCmEntityColor* trueColors() const;

    void setMappingCoords (MapChael mapChael, const UcGePoint3d* pCoords);
    UcGePoint3d* mappingCoords (MapChael mapChael) const;
private:
	UcGiImpVertexData *mpUcGiImpVertexData;
};

class UcGiTextStyle: public UcRxObject
{ 
public:
	UCRX_DECLARE_MEMBERS(UcGiTextStyle);
    ~UcGiTextStyle();
    UcGiTextStyle(UcDbDatabase* pDb = NULL);

    UcGiTextStyle(
        const ZTCHAR*  fontName,
        const ZTCHAR*  bigFontName,
        const double textSize,
        const double xScale,
        const double obliqueAngle,
        const double trPercent,

        const ZSoft::Boolean isBackward,
        const ZSoft::Boolean isUpsideDown,
        const ZSoft::Boolean isVertical,

        const ZSoft::Boolean isOverlined,
        const ZSoft::Boolean isUnderlined,
		const ZSoft::Boolean isStrikethrough = false,
        const ZTCHAR*          styleName = NULL);

    virtual int loadStyleRec(UcDbDatabase* pDb = NULL) const;
    virtual void setTextSize(const double size);
    virtual void setXScale(const double xScale);
    virtual void setObliquingAngle(const double obliquingAngle);

    virtual void setTrackingPercent(const double trPercent);

    virtual void setBackward(const ZSoft::Boolean isBackward);
    virtual void setUpsideDown(const ZSoft::Boolean isUpsideDown);
    virtual void setVertical(const ZSoft::Boolean isVertical);

    virtual void setUnderlined(const ZSoft::Boolean isUnderlined);
    virtual void setOverlined(const ZSoft::Boolean isOverlined);
	virtual void setStrikethrough(const ZSoft::Boolean isStrikethrough);

    virtual void setFileName(const ZTCHAR * fontName);
    virtual void setBigFontFileName(const ZTCHAR * bigFontFileName);

    virtual double textSize() const;
    virtual double xScale() const;
    virtual double obliquingAngle() const;

    virtual double trackingPercent() const;

    virtual ZSoft::Boolean isBackward() const;
    virtual ZSoft::Boolean isUpsideDown() const;
    virtual ZSoft::Boolean isVertical() const;

    virtual ZSoft::Boolean isUnderlined() const;
    virtual ZSoft::Boolean isOverlined() const;
	virtual ZSoft::Boolean isStrikethrough() const;

    virtual const ZTCHAR * fileName() const;
    virtual const ZTCHAR * bigFontFileName() const;

    virtual UcGePoint2d extents(const ZTCHAR * pStr,
                const ZSoft::Boolean penups,
                const int len,
                const ZSoft::Boolean raw,
                UcGiWorldDraw *ctxt = NULL) const;

    virtual const ZTCHAR * styleName() const;
    virtual Ucad::ErrorStatus setStyleName(const ZTCHAR *);

    virtual Ucad::ErrorStatus setFont(const ZTCHAR * pTypeface,
                                      ZSoft::Boolean bold,
                                      ZSoft::Boolean italic,
                                      int charset, int pitchAndFamily);

    virtual Ucad::ErrorStatus font(ZTCHAR *& pTypeface, ZSoft::Boolean& bold,
                ZSoft::Boolean& italic, int& charset, int& pitchAndFamily) const;

    virtual Ucad::ErrorStatus  extentsBox(  const ZTCHAR * pStr,
                                            const ZSoft::Boolean penups,
                                            const int len,
                                            const ZSoft::Boolean raw,
                                            UcGePoint2d &extMin,
                                            UcGePoint2d &extMax,
                                            UcGiWorldDraw *ctxt = NULL) const;

    virtual void setTrackKerning(double trackPercent) const;

    virtual bool preLoaded() const;
    virtual void setPreLoaded(bool);

private:
	friend class UcGiImpTextStyle;
	UcGiImpTextStyle *mpUcGiImpTextStyle;
};

#pragma pack (pop)

#endif
